<?php
include ('accesBDD.php');
	class Changemdp {
	private $email;
	private $mdp;
	private $newmdp;

	//Un constructeur	
	public function __construct ($email , $mdp , $newmdp) {
	$this->email = $email;
	$this->mdp = $mdp;
	$this->newmdp = $newmdp;
	
	}
		
		public function verif() {

		$req = "SELECT count(*) FROM utilisateur WHERE(email='$this->email' AND mdp='$this->mdp')";
		$res = mysql_query($req);
		$itsOk=mysql_fetch_row ($res);
		return($itsOk[0] !=0);
		}
		
		
		
		public function change() {
		if ($this->verif()){	
		$req = "UPDATE utilisateur SET mdp='$this->newmdp' WHERE email = '$this->email'";
		$itsOk= mysql_query($req);
		echo 'Mise à jour réussie !';
		return($itsOk);
		}
		else {
		echo'Ancien mot de passe éronné';

		}

	}
	}
		
		
		

?>
